<?php

/**
 * Description of lang
 *
 */
class lang {

    # singleton instance holder
    private static $instance;

    # returns singleton instance
    public static function __l() {
        if (!isset(self::$instance)) {
            $className = __CLASS__;
            self::$instance = new $className;
        }
        return self::$instance;
    }

    /**
     * Getter method.
     * 
     * lang::__l()->get(2,'Hi');
     * 
     * if $this->lang_2 is set than return associated value 
     * else it returns default value passed.
     * 
     * @param integer $id
     * @param string $default
     * @return string
     * 
     * @todo dynamically add entries to database.
     */
    public function get($id, $default='') {
        return isset($this->lang_{$id}) ? $this->lang_{$id} : $default;
    }

    /**
     * Sets $this->lang_1.
     * 
     * during page execution, all lang variable requied for given registry
     * are supposed to set lang variable 
     * 
     * @param integer $id
     * @param string $value 
     */
    public function set($id, $value) {
        $this->lang_{$id} = $value;
        $this->get_registry_data();
    }
    
    public function get_registry_data(){
        
    }

}

?>
